import csv
import json
def csv_to_json(csv_file_path, json_file_path):
    # 读取CSV文件
    with open(csv_file_path, 'r', encoding='gbk') as csv_file:
        csv_data = csv.DictReader(csv_file)
        # 将CSV数据转换为字典列表
        data = list(csv_data)
        # 将字典列表转换为JSON格式
        json_data = json.dumps(data, indent=4, ensure_ascii=False)
        # 将JSON数据写入文件
        with open(json_file_path, 'w', encoding='utf-8') as json_file:
            json_file.write(json_data)
# 指定CSV文件路径和JSON文件路径
csv_file_path = 'sellData.csv'
json_file_path = 'saleData.json'
# 调用函数进行转换
csv_to_json(csv_file_path, json_file_path)